<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Builds and solves a simple linear program</title>
<link rel="canonical" href="/Users/mcgrant/Projects/CVX/examples/html/simple_LP.html">
<link rel="stylesheet" href="../examples.css" type="text/css">
</head>
<body>
<div id="header">
<h1>Builds and solves a simple linear program</h1>
Jump to:&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#source">Source code</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#output">Text output</a>
&nbsp;&nbsp;&nbsp;&nbsp;
Plots
&nbsp;&nbsp;&nbsp;&nbsp;<a href="../index.html">Library index</a>
</div>
<div id="content">
<a id="source"></a>
<pre class="codeinput">
echo <span class="string">on</span>

n = 100;
A = randn(0.5*n,n);
b = randn(0.5*n,1);
c = randn(n,1);
d = randn;
cvx_begin
   variable <span class="string">x(n)</span>
   dual <span class="string">variables</span> <span class="string">y</span> <span class="string">z</span>
   minimize( c' * x + d )
   subject <span class="string">to</span>
      y : A * x == b;
      z : x &gt;= 0;
cvx_end

echo <span class="string">off</span>
</pre>
<a id="output"></a>
<pre class="codeoutput">
n = 100;
A = randn(0.5*n,n);
b = randn(0.5*n,1);
c = randn(n,1);
d = randn;
cvx_begin
   variable x(n)
   dual variables y z
   minimize( c' * x + d )
   subject to
      y : A * x == b;
      z : x &gt;= 0;
cvx_end
 
Calling SDPT3 4.0: 100 variables, 50 equality constraints
------------------------------------------------------------

 num. of constraints = 50
 dim. of linear var  = 100
*******************************************************************
   SDPT3: Infeasible path-following algorithms
*******************************************************************
 version  predcorr  gam  expon  scale_data
    NT      1      0.000   1        0    
it pstep dstep pinfeas dinfeas  gap      prim-obj      dual-obj    cputime
-------------------------------------------------------------------
 0|0.000|0.000|8.8e+01|1.1e+01|1.3e+04|-1.086578e+02  0.000000e+00| 0:0:00| chol  1  1 
 1|0.551|0.656|3.9e+01|4.0e+00|6.7e+03|-1.631934e+02  1.126747e+01| 0:0:00| chol  1  1 
 2|0.566|0.634|1.7e+01|1.5e+00|3.6e+03|-1.724378e+02  1.022269e+01| 0:0:00| chol  1  1 
 3|0.633|1.000|6.3e+00|8.4e-04|1.6e+03|-1.064707e+02  6.512959e+00| 0:0:00| chol  1  1 
 4|0.861|1.000|8.8e-01|8.4e-05|2.2e+02|-1.575731e+01  1.250119e+01| 0:0:00| chol  1  1 
 5|0.432|0.405|5.0e-01|5.3e-05|1.4e+02|-8.921348e+00  5.963030e+01| 0:0:00| chol  1  1 
 6|0.201|0.149|4.0e-01|4.5e-05|1.3e+02|-6.627935e+00  1.218798e+02| 0:0:00| chol  1  1 
 7|0.129|0.240|3.5e-01|3.4e-05|2.0e+02|-6.692783e+00  4.888720e+02| 0:0:00| chol  1  1 
 8|0.124|0.047|3.0e-01|3.3e-05|1.7e+02|-5.321391e+00  1.041341e+03| 0:0:00| chol  1  1 
 9|0.045|0.034|2.9e-01|3.2e-05|3.3e+02|-5.465013e+00  4.551880e+03| 0:0:00| chol  1  1 
10|0.015|0.309|2.9e-01|2.2e-05|2.0e+04|-5.133319e+00  4.316776e+05| 0:0:00| chol  2  2 
11|0.020|0.027|2.8e-01|2.1e-05|1.6e+05|-4.888567e+00  7.136656e+06| 0:0:00| chol  2  2 
12|0.008|0.002|2.8e-01|2.1e-05|5.2e+05|-4.808494e+00  3.654444e+07| 0:0:00| chol  2  2 
13|0.003|0.030|2.8e-01|2.1e-05|6.3e+07|-4.742335e+00  5.661729e+09| 0:0:00| chol  2  2 
14|0.007|1.000|2.7e-01|1.0e-02|1.9e+11|-4.692530e+00  4.747595e+13| 0:0:00| chol  2  2 
15|0.003|1.000|2.7e-01|5.9e+02|3.1e+15|-4.643357e+00  3.047492e+18| 0:0:00|
  sqlp stop: primal problem is suspected of being infeasible
-------------------------------------------------------------------
 number of iterations   = 15
 residual of primal infeasibility      
 certificate (y,Z)      = 2.34e-15
 reldist to infeas.    &lt;= 3.64e-17
 Total CPU time (secs)  = 0.12  
 CPU time per iteration = 0.01  
 termination code       =  1
 DIMACS: 7.6e-01  0.0e+00  2.0e+03  0.0e+00  -1.0e+00  1.0e-03
-------------------------------------------------------------------
 
------------------------------------------------------------
Status: Infeasible
Optimal value (cvx_optval): +Inf
 

echo off
</pre>
</div>
</body>
</html>